package com.itheima.thread.communication.demo03;

public class CustomerThread implements Runnable {

    private Box box;
    public CustomerThread(Box box) {
        this.box = box;
    }

    @Override
    public void run() {

        while (true) {

            synchronized (box) {

                if(!box.isFlag()) {
                    try {
                        box.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                System.out.println(box.getMilkType() + "----" + box.getAmount());

                box.setFlag(false);

                box.notify();

            }

        }

    }
}
